plik_path = "/tmp/numbers.txt" #Defining the plik_path


def get_number():               #definig first function
   

    plik = open(plik_path, "a")             #opening the file

    while True:

        number = raw_input("Give a total number:")     #askimng for the number

        if number.isdigit():                                  
           
            numbers = '%s,'% (number)             #defining numbers

            plik.write(numbers)                     #writing to the file

            return number
            break

        print "This is not a total number . Use totalnumbers only."
   

def next_number():                  #defining second function

    ask = raw_input('Want to give next number?(y/n)')             #asking if you want next number

    if not ask in ("y","n","Y","N"):            #if awnser is not t or n repeat
        print "Wpisz t lub n"
        next_number()

    if ask == "y" or ask == "Y":                      #if awnser is t askfor next number
        get_number()
        next_number()
    if ask == "n" or ask == "N":                      #if awnser is n we start reading fromda files
        plik =open(plik_path, "r")      #open file

        num = plik.read()             #reading the file

        num = num[:-1]                  #reamoving the last number to  avoid errors
       
        num = num.split(",")      #splitin the file
        
        x = 0

        while x < len(num):
            num[x] = int(num[x])
            x = x + 1



        print "liczba liczb:",len(num),"\n","najwiekszaliczba:",max(num),"\n","najmniejsza liczba:",min(num) #printing the number
        

        plik.close                      #closeing the file


while True:                             #running the program
   
    get_number()
    next_number()
    break
